<!--Here we have automatic session tracking-->
<html>
<head>
<!--Countly script-->
<script type='text/javascript' src='../../lib/countly.js'></script>
<script type='module'>
import { queryExtractor } from '../support/integration_helper.js';
// here we implement a cookie and localStorage clearing logic
const deleteAllCookies = () => {
const cookies = document.cookie.split(";");
for (const cookie of cookies) {
    const eqPos = cookie.indexOf("=");
    const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
    document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
  }
}
window.localStorage.clear();
deleteAllCookies();
console.error("cleared the storage");

// we extract the url query and dissect the embedded configuration object within
const confObj = queryExtractor(window.location.search);

//initializing countly with params
Countly.init({
	app_key: "YOUR_APP_KEY",
	url: "https://your.domain.countly",
  device_id: "auto",
  session_update: 4,
  test_mode: true,
  use_session_cookie: confObj.use_session_cookie || false,
	debug:true
})
Countly.track_sessions();
// Countly.track_pageview();
</script>
</head>
<body>
<script type='text/javascript' >
function clickEvent(){
	Countly.add_event({
    key: "buttonClick",
    "segmentation": {
        "id": "id"
    }
});
}
</script>
<button type="button" onclick="clickEvent()">Event</button>
</body>
</html>
